//
//  MerchantDetailVC.m
//  BigJoy
//
//  Created by Rowling on 2017/7/13.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "MerchantDetailVC.h"
#import "SDCycleScrollView.h"
#import "IntroduceCell.h"
#import "MerchantPeopleCell.h"
#import "MerchantRecommendCell.h"
#import "BuyView.h"

@interface MerchantDetailVC ()<SDCycleScrollViewDelegate>
@property (nonatomic,strong) SDCycleScrollView *cycleView;
@property (weak, nonatomic) IBOutlet UIView *navView;
@property (weak, nonatomic) IBOutlet UIView *contentView;

@end

@implementation MerchantDetailVC

-(SDCycleScrollView *)cycleView {
    if(_cycleView == nil) {
        _cycleView = [[SDCycleScrollView alloc]init];
        _cycleView.delegate = self;
        _cycleView.autoScrollTimeInterval = 4;
        _cycleView.bannerImageViewContentMode = 2;
        _cycleView.backgroundColor = [UIColor whiteColor];
        _cycleView.pageDotColor = [UIColor clearColor];
        _cycleView.currentPageDotColor = [UIColor whiteColor];
    }
    return  _cycleView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.contentView addSubview:self.XMTableview];
    [self.XMTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.right.equalTo(self.contentView);
    }];
    self.XMTableview.estimatedRowHeight = 150;
    [self addHeader];
}

-(void)addHeader {
    self.cycleView.localizationImageNamesGroup = @[@"1.jpeg",@"2.jpeg",@"test.jpg"];    
    self.cycleView.frame = CGRectMake(0, 0, SCREEN_WIDTH, XMW(342));
    self.XMTableview.tableHeaderView = self.cycleView;
    self.XMTableview.separatorStyle = 1;
}

/** 点击图片回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
}
- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)shareButtonClick:(id)sender {
}


#pragma -mark:tableviewDelegate

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        IntroduceCell * cell = [IntroduceCell cellWithTalbelView:tableView];
        return cell;
    }else if(indexPath.row == 1){
        MerchantPeopleCell * cell = [MerchantPeopleCell cellWithTalbelView:tableView];
        return cell;
    }else {
        MerchantRecommendCell * cell = [MerchantRecommendCell cellWithTalbelView:tableView];
        return cell;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return UITableViewAutomaticDimension;
    }else if(indexPath.row == 1){
        return 96;
    }else {
        return XMW(227);
    }
}
// 购买
- (IBAction)buyButtonClick:(id)sender {
    BuyView * buyView= [[BuyView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [buyView animationShowWithView:XMKEYWINDOWXM];
}

@end
